package com.github.elliot.usercenter.dao;

import com.github.elliot.usercenter.po.User;
import org.springframework.data.r2dbc.repository.Modifying;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Mono;

@Repository
public interface UserRepository extends R2dbcRepository<User, Integer>, UserInnerRepository {

    @Query(value = "select * from user WHERE username = :username")
    Mono<User> findUserByUsername(String username);

    @Query(value = "select * from user WHERE user_no = :userNo")
    Mono<User> findByUserNo(String userNo);

    @Modifying
    @Query(value = "UPDATE user set del_flag = 1 WHERE user_no = :userNo")
    Mono<Void> updateByUserNo(String userNo);

}
